<?php
class XSmartyView extends XAbstractView{
	protected $extesion = 'tpl';
	protected static $smarty = null;
	
	function __construct() {
		if (!self::$smarty) {
			self::$smarty = &XSmarty::load();
		}
		$compile_dir = PROJECT_ROOT.'/tmp/templates_c';
		if(!file_exists($compile_dir)) {
			@mkdir($compile_dir, 0777, true);
		}
		self::$smarty->compile_dir = $compile_dir;
		self::$smarty->debugging = false;
	}
		
	public function view(){
		self::$smarty->assign($this->contents);
		$name = x_name_to_c(preg_replace("/^do/e", "", $this->name));
		$file = PROJECT_ROOT.'/views/'.$this->route.'/'.$name.'.'.$this->extesion;
		if(!file_exists($file)){
			return;
		}
		self::$smarty->display("file:".$file);
	}
}
?>